package com.xuqm.sdhbwfu.app.repository

import com.xuqm.sdhbwfu.app.data.*
import com.xuqm.sdhbwfu.app.model.*
import com.xuqm.sdhbwfu.core.model.HttpResult
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.*
import java.util.*


interface Service {
    /**
     * 登录
     */
    @POST("mobilelogin")
    fun login(@Body user: LoginData): Observable<HttpResult<String>>

//    @POST("login")
//    fun login(@Body user: LoginData): Observable<HttpResult<String>>

    /**
     * 任务列表
     */
    @GET("dcom/api/w/inspection/task")
    fun inspectionList(
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("s_status") s_status: String
    ): Observable<HttpResult<List<InspectionListModel>>>

    /**
     * 领取任务
     */
    @PUT("dcom/api/w/inspection/task/claim/{id}")
    fun inspectionGet(
        @Path("id") id: Int,
    ): Observable<HttpResult<String>>

    /**
     * 更新状态
     */
    @PUT("dcom/api/w/inspection/task/project/{id}")
    fun inspectionUpdate(
        @Path("id") id: Int, @Body model: JobListModel
    ): Observable<HttpResult<JobListModel>>

    /**
     * 提交作业
     */
    @PUT("dcom/api/w/inspection/task/submit/{id}")
    fun inspectionConfirm(
        @Path("id") id: Int
    ): Observable<HttpResult<InspectionListModel>>


    /**
     * 获取巡检任务列表
     */
    @GET("dcom/api/w/inspection/task/project/{id}")
    fun jobList(
        @Path("id") id: Int,
    ): Observable<HttpResult<List<JobListModel>>>

    /**
     * 获取巡检任务列表
     */
    @GET("dcom/api/w/dutyManager/current")
    fun schedulingList(): Observable<HttpResult<List<SchedulingModel>>>

    /**
     * 位置树查询
     */
    @GET("cmdb/instances/schema/SM_LOCATION/tree/by/parent")
    fun locationList(): Observable<HttpResult<List<RiskLoacationModel>>>

    /**
     * 类型树查询
     */
    @GET("cmdb/schemas/tree/pure")
    fun pureList(): Observable<HttpResult<List<RiskPureModel>>>

    /**
     * 可选择人员列表
     */
    @GET("auth/api/w/auth/users?s_roleCode=devOpsManager")
    fun userList(): Observable<HttpResult<List<RiskUserModel>>>

    /**
     * 新建风险单
     */
    @POST("dcom/api/w/risk/applyform")
    fun applyForm(@Body data: RiskCreateData): Observable<HttpResult<RiskCreateModel>>

    /**
     * 设备查询
     */
    @GET("cmdb/instances/schema/{schemadef}")
    fun schemaList(
        @Path("schemadef") schemadef: String,
        @Query("s_location") s_location: String
    ): Observable<HttpResult<List<RiskSchemaModel>>>

    /**
     * 我的待办工单信息
     * page=0&size=1&sort=updateTime,desc&s_type=risk
     */
    @GET("dcom/api/w/act/workorders/todo/p")
    fun todoList(
        @Query("page") page: Int,
        @Query("size") size: Int,
        @Query("sort") sort: String,
        @Query("s_type") s_type: String,
    ): Observable<HttpResult<ArrayList<ItemRiskList>>>

    /**
     * 获取工单履历
     */
    @GET("dcom/api/w/act/workorders/records/{workNum}")
    fun recordList(
        @Path("workNum") workNum: String,
    ): Observable<HttpResult<ArrayList<RecordModel>>>

    /**
     * 查看风险申请表单
     */
    @GET("dcom/api/w/risk/applyform/{workNum}/{taskId}")
    fun applyform(
        @Path("workNum") workNum: String,
        @Path("taskId") taskId: String,
    ): Observable<HttpResult<ApplyformModel>>

    /**
     * 查看判断申请表单
     */
    @GET("dcom/api/w/risk/judgmentform/{workNum}/{taskId}")
    fun judgmentform(
        @Path("workNum") workNum: String,
        @Path("taskId") taskId: String,
    ): Observable<HttpResult<JudgmentformModel>>

    /**
     * 查看风险处理表单
     */
    @GET("dcom/api/w/risk/managementform/{workNum}/{taskId}")
    fun managementform(
        @Path("workNum") workNum: String,
        @Path("taskId") taskId: String,
    ): Observable<HttpResult<ManagementformModel>>

    /**
     * 提交风险处理表单
     */
    @POST("dcom/api/w/risk/managementform")
    fun confirmform(@Body data: RiskTodoConfirmData): Observable<HttpResult<ManagementformModel>>

    /**
     * 上传图片
     */
    @POST("dcom/api/w/inspection/task/project/attachment")
    @Streaming
    fun picUpload(@Body body: RequestBody): Observable<HttpResult<UploadModel>>

    /**
     * 上传风险单附件
     */
    @POST("dcom/api/w/risk/applyform/upload/annex")
    @Streaming
    fun annex(@Body body: RequestBody): Observable<HttpResult<RiskUploadModel>>

    /**
     * 上传风险单附件
     */
    @POST("dcom/api/w/risk/managementform/upload/annex")
    @Streaming
    fun annexManagementform(@Body body: RequestBody): Observable<HttpResult<RiskUploadModel>>


    /**
     * 维护任务列表
     */
    @GET("uptime/api/w/pmTask/search")
    fun pmTaskList(): Observable<HttpResult<ArrayList<PmTaskModel>>>

    /**
     * 提交实施内容
     */
    @POST("uptime/api/w/pmTask/implementationContent/update")
    fun updatePmTask(@Body data: PmTaskContent): Observable<HttpResult<PmTaskContent>>

    /**
     * 提交先提条件
     */
    @POST("uptime/api/w/pmTask/firstCondition/submit")
    fun submitFirst(@Body data: SignData): Observable<HttpResult<SignModel>>

    /**
     * 提交安全保障
     */
    @POST("uptime/api/w/pmTask/safetyGuarantee/submit")
    fun submitSafety(@Body data: SignSafetyData): Observable<HttpResult<SignModel>>

    /**
     * 提交工具准备
     */
    @POST("uptime/api/w/pmTask/toolPreparation/submit")
    fun submitTool(@Body data: SignToolData): Observable<HttpResult<SignModel>>

    /**
     * 提交备料准备
     */
    @POST("uptime/api/w/pmTask/materialPreparation/submit")
    fun submitMaterial(@Body data: SignMaterialData): Observable<HttpResult<SignModel>>

    /**
     * 备料准备，程序执行中的执行项都是用这个api提交。
     */
    @POST("uptime/api/w/pmTask/executableContent/update")
    fun submitExecutable(@Body data: PmTaskContent): Observable<HttpResult<PmTaskContent>>

    /**
     * 提交维护实施签名
     */
    @POST("uptime/api/api/w/pmTask/stepMainItem/submit")
    fun submitPm(@Body data: SignPmData): Observable<HttpResult<SignModel>>

    /**
     * 根据id获取实施列表
     */
    @GET("/uptime/api/w/pmTask/stepMain/{id}")
    fun stepMainList(@Path("id") id: String): Observable<HttpResult<PmTaskModel.StepMain>>

    /**
     * 上传签名图片
     */
    @POST("/uptime/api/w/files/upload")
    @Streaming
    fun signUpload(@Body body: RequestBody): Observable<HttpResult<SginModel>>

    /**
     * 完成维护实施
     */
    @POST("uptime/api/w/pmTask/stepMain/submit")
    fun finish(@Body data: FinishData): Observable<HttpResult<SignModel>>

    /**
     * 完成维护实施
     */
    @POST("uptime/api/w/pmTask/stepMain/createItem")
    fun createItem(@Body data: CreateItemData): Observable<HttpResult<SignModel>>
    /**
     * 完成维护实施
     */
    @GET("uptime/api/w/pmTask/stepMainItem/{id}")
    fun refresh(@Path("id") id: String): Observable<HttpResult<SignModel>>

}